const app = getApp();
const Controller = require('../controllers/controllers.js').controller;
Page({
  data: {
    page:1,
    pageSize:10,
    isEnd:false,
    lists:[],
    userInfo:'',
  },
  onLoad: function (options) {
    if(options.parentid){
      app.globalData.parentid=options.parentid
    }
  },
  onShow: function () {
    this.setData({
      page:1,
      pageSize:10,
      isEnd:false,
      lists:[],
      userInfo:'',
    })
    this.userScoreRecordList()
    this.info()
  },
  info(){
    Controller.info().then(res=>{
      if(res.data.baseData){
        this.setData({
          userInfo:res.data.baseData
        })
      }
    })
  },
  userScoreRecordList(){
    var data={
      page:this.data.page,
      pageSize:this.data.pageSize
    }

    Controller.userScoreRecordList(data).then(res=>{
      if(res.data.baseData && res.data.baseData.list.length>0){
        res.data.baseData.more=false;
        this.setData({
          lists:this.data.lists.concat(res.data.baseData.list),
        })
      }
      if(res.data.baseData.lastPage){
        this.setData({
          isEnd:res.data.baseData.lastPage
        })
      }
    })
  },
  onReachBottom(){
    if(this.data.isEnd){
      return
    }else{
      this.setData({
        page:this.data.page+1
      })
      this.userScoreRecordList()
    }
    
  },
  explain(){
    wx.navigateTo({
      url: "/pages/doc/doc?key=key-score-info&name=积分说明"
    })
  },
  onShareAppMessage: function (e) {
    let title = '';
    let imageUrl = '';
    let path=app.getCurrentPageUrlWithArgs()
    let obj = {
      title,
      imageUrl,
      path,
      success: function (res) {},
      fail(err) {}
    }
    return obj
  },
  onShareTimeline: function(res){
    let title = '';
    let imageUrl = '';
    let path=app.getCurrentPageUrlWithArgs()
    let obj = {
      title,
      imageUrl,
      path,
      success: function (res) {},
      fail(err) {}
    }
    return obj
  },
})